﻿@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Jsonp</title>

</head>
<body>
    <div>
        <a id="btn" style="padding:10px 25px;border:1px solid red;">JSONP</a>

        <a id="btn2" style="padding:10px 25px;border:1px solid red;">WebApi</a>

        <a id="btn3" style="padding:10px 25px;border:1px solid red;">WebApi333</a>
    </div>
    <script src="~/Scripts/jquery.min.js"></script>
    <script>
        $(function () {
            $("#btn").click(function () {
                console.log(1);
                $.ajax({
                    type: "POST",
                    url: "http://www.see2eyes.cn:8080/Todo/GetInformation?callback=localJsonpCallback",
                    dataType: "jsonp",
                    data: "id=5&LoginName=arno&Password=123",
                    jsonpCallback: "localJsonpCallback",
                    success: function (result) {
                        console.log(JSON.stringify(result));
                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {  //#3这个error函数调试时非常有用，如果解析不正确，将会弹出错误框
                        alert(XMLHttpRequest.status);
                        alert(XMLHttpRequest.readyState);
                        alert(textStatus); // paser error;
                    },
                    beforeSend: function () {
                        console.log("before");
                    },
                    complete: function () {
                        console.log("complete");
                    }
                });
            })

            $("#btn2").click(function () {
                console.log(222);
                $.ajax({
                    type: "GET",
                    url: "http://www.see2eyes.cn:8080/api/apitodo",
                    dataType: "jsonp",
                    data: "LoginName=arno&Password=123",
                    jsonpCallback: "localJsonpCallback",
                    jsonp: "callback",
                    success: function (result) {
                        console.log(JSON.stringify(result));
                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {  //#3这个error函数调试时非常有用，如果解析不正确，将会弹出错误框
                        alert(XMLHttpRequest.status);
                        alert(XMLHttpRequest.readyState);
                        alert(textStatus); // paser error;
                    },
                    beforeSend: function () {
                        console.log("before");
                    },
                    complete: function () {
                        console.log("complete");
                    }
                });
            })

            $("#btn3").click(function () {
                console.log(333);
                $.ajax({
                    type: "GET",
                    url: "http://www.see2eyes.cn:8080/api/apitodo",
                    dataType: "json",
                    data: "callback=localJsonpCallback&LoginName=arno&Password=123",
                    success: function (result) {
                        console.log(JSON.stringify(result));
                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {  //#3这个error函数调试时非常有用，如果解析不正确，将会弹出错误框
                        alert(XMLHttpRequest.status);
                        alert(XMLHttpRequest.readyState);
                        alert(textStatus); // paser error;
                    },
                    beforeSend: function () {
                        console.log("before");
                    },
                    complete: function () {
                        console.log("complete");
                    }
                });
            })
        })
    </script>
</body>
</html>
